<?php

/**
 * Comprobante filter form base class.
 *
 * @package    sf_sandbox
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseComprobanteFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'fecha_emision'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'nro_comprobante'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'importe_cuota'       => new sfWidgetFormFilterInput(),
      'unidad_funcional_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('UnidadFuncional'), 'add_empty' => true)),
      'tipo_comprobante_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TipoComprobante'), 'add_empty' => true)),
      'lectura_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Lectura'), 'add_empty' => true)),
      'categoria_agua_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CategoriaAgua'), 'add_empty' => true)),
      'periodo_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Periodo'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'fecha_emision'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'nro_comprobante'     => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'importe_cuota'       => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'unidad_funcional_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('UnidadFuncional'), 'column' => 'id')),
      'tipo_comprobante_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('TipoComprobante'), 'column' => 'id')),
      'lectura_id'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Lectura'), 'column' => 'id')),
      'categoria_agua_id'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('CategoriaAgua'), 'column' => 'id')),
      'periodo_id'          => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Periodo'), 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('comprobante_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Comprobante';
  }

  public function getFields()
  {
    return array(
      'id'                  => 'Number',
      'fecha_emision'       => 'Date',
      'nro_comprobante'     => 'Number',
      'importe_cuota'       => 'Number',
      'unidad_funcional_id' => 'ForeignKey',
      'tipo_comprobante_id' => 'ForeignKey',
      'lectura_id'          => 'ForeignKey',
      'categoria_agua_id'   => 'ForeignKey',
      'periodo_id'          => 'ForeignKey',
    );
  }
}
